package com.tepth.remote.control.delegate.pick;

import com.tepth.remote.control.base.bean.Project;
import com.tepth.remote.ui.recycler.BaseDataConverter;
import com.tepth.remote.ui.recycler.ItemType;
import com.tepth.remote.ui.recycler.MultipleFields;
import com.tepth.remote.ui.recycler.MultipleItemEntity;

import java.util.ArrayList;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/20
 */
public class PickDataConvert extends BaseDataConverter {
    @Override
    public ArrayList<MultipleItemEntity> convert() {
        final ArrayList<Project> projectArray = getProjectArray();
        final int size = projectArray.size();
        for (int i = 0; i < size; i++) {
            final Project project = projectArray.get(i);
            final String title = project.getPro_Name();
            final MultipleItemEntity entity = MultipleItemEntity.builder()
                    .setItemType( ItemType.PROJECT_PAGER)
                    .setField(MultipleFields.TEXT, title)
                    .setField(MultipleFields.PROJECT, project)
                    .setField(MultipleFields.IS_PULL, true)
                    .setField(MultipleFields.POSITION, i)
                    .builder();
            ENTITIES.add(entity);
        }
        return ENTITIES;
    }

    private ArrayList<Project> getProjectArray() {
        final ArrayList<Project> projectArray = new ArrayList<>();
        final ArrayList<Object> array = getArrays();
        final int size = array.size();
        for (int i = 0; i < size; i++) {
            projectArray.add((Project) array.get(i));
        }
        return projectArray;
    }

    ArrayList<Object> convertProjectToObject(ArrayList<Project> arrayList) {
        final ArrayList<Object> objects = new ArrayList<>();
        final int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            objects.add(arrayList.get(i));
        }
        return objects;
    }
}
